//
//  RTreeUtils.h
//  map-matching
//
//  Created by Lv Xin on 16/5/12.
//  Copyright © 2016年 Lv Xin. All rights reserved.
//

#ifndef RTreeUtils_h
#define RTreeUtils_h

#include <stdio.h>
#include <vector>
#include <cstring>
#include "RTree.h"

using namespace std;

struct Rect
{
    double first;
    double second;
    int id;
    double distance;
    Rect () {
    }
    ~Rect () {
    }
    Rect (double id1, double id2, int id, double distance) {
        this -> first = id1;
        this -> second = id2;
        this -> id = id;
        this -> distance = distance;
    }
};

struct Rectd {
    Rectd() {
    }
    
    Rectd(double a_minX, double a_minY, double a_maxX, double a_maxY,
          Rect v) {
        min[0] = a_minX;
        min[1] = a_minY;
        
        max[0] = a_maxX;
        max[1] = a_maxY;
        
        vid = v;
    }
    
    double min[2];
    double max[2];
    Rect vid;
};

bool MySearchCallback(Rect id, void* arg);

void CreateRTree(vector<struct Rectd> rects, RTree<Rect, double, 2, float> &tree);

void SearchRTree(struct Rectd search_rect, RTree<Rect, double, 2, float> &tree);

void TraverseRTree(RTree<Rect, double, 2, float> &tree);

#endif /* RTreeUtils_h */
